package yingke.com.yingke.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

import com.avos.avoscloud.AVUser;

import yingke.com.yingke.R;

import static yingke.com.yingke.MyApp.loginState;

public class SettingActivity extends AppCompatActivity implements View.OnClickListener {

    private Toolbar setting_tb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_setting);
        initView();
        lisenter();
    }

    private void lisenter() {
        setting_tb.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initView() {
        findViewById(R.id.setting_exit_bt).setOnClickListener(this);
        setting_tb = (Toolbar) findViewById(R.id.setting_tb);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.setting_exit_bt://退出登录
                AVUser.logOut();// 清除缓存用户对象
                Toast.makeText(this, "用户退出成功", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(SettingActivity.this,LoginActivity.class));
                loginState=false;
                finish();
                break;
        }
    }
}
